package com.atguigu.test

import java.sql.Timestamp

import org.apache.flink.streaming.api.scala._

import scala.util.Random

object WordCount {


  case class Word(str: String, i: Int)


  def main(args: Array[String]): Unit = {
    // 创建流处理环境
    val env = StreamExecutionEnvironment.getExecutionEnvironment
    env.setParallelism(1)
    val stream = env.fromElements("fdsalkfjhl",
    "fasfsdf d dsfdfsaf ",
    "fsjakf fsafe")
    val tr = stream
      .flatMap(line => line.split("\\s"))
      .map(w => Word(w, 1))
      .keyBy(0)
      .sum(1)
    tr.print()

    env.execute()


  }
}
